package com.tianyang.yukuaifuzs.business.main.adapter;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tianyang.yukuaifuzs.R;
import com.tianyang.yukuaifuzs.business.main.bean.UserStoreOutput;
import com.tianyang.yukuaifuzs.common.utils.CommonUtils;
import com.tianyang.yukuaifuzs.utils.DateUtils;

import java.util.ArrayList;

/**
 * Description：店铺门店管理
 * Created by xyj on 2024/3/11
 */
public class StoreManageAdapter extends BaseQuickAdapter<UserStoreOutput, BaseViewHolder> {

    private int memberId;

    public StoreManageAdapter(int memberId) {
        super(R.layout.item_store_manage, new ArrayList<>());
        this.memberId = memberId;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, UserStoreOutput item) {
        if (item != null) {
            helper.setText(R.id.usernameTv, "店铺编号：" + item.getUsername())
                    .setText(R.id.createTimeTv, "申请时间：" + DateUtils.formatTime(item.getCreateTime()))
                    .setText(R.id.typeTv, CommonUtils.getMerchantName(item.getProductRecommendAge()))
                    .setText(R.id.statusTv, getStatus(item.getPosStatus()));
            ImageView changeIv = helper.getView(R.id.changeIv);
            if (item.getId() != memberId) {
                changeIv.setVisibility(View.VISIBLE);
                helper.addOnClickListener(R.id.changeIv);
            } else {
                changeIv.setVisibility(View.GONE);
            }
        }
    }

    private String getStatus(int posStatus) {
        if (posStatus < 0) {
            return "认证状态：已驳回";
        } else if (posStatus == 0) {
            return "认证状态：待提交";
        } else if (posStatus == 1) {
            return "认证状态：审核中";
        } else if (posStatus == 2) {
            return "认证状态：待授权";
        } else if (posStatus == 3) {
            return "认证状态：待绑定";
        } else if (posStatus == 4) {
            return "认证状态：已认证";
        }
        return "待提交";
    }
}
